/*
day43
2019.10.10
*/
#include<stdlib.h>
#include<stdio.h>


struct ListNode {
    int val;
    struct ListNode *next;
};


struct ListNode *last_n(struct ListNode *head,int n)
{
	struct ListNode *fast=head, *slow=head;
	for(int i=0;i<n;i++)
	{
		fast=fast->next;
	}
	while(fast)
	{
		fast=fast->next;
		slow=slow->next ;
	}
	return slow;
}

struct ListNode* rotateRight(struct ListNode* head, int k){
	if(!head||k==0)
	{
		return head;
	}
	
	struct ListNode *p=head,*last;
	int len=0;
	while(p)
	{
		len++;
		last=p;
		p=p->next;
		
	}
	printf("%d",last->val);
	int step=k%len;
	
	struct ListNode *div=last_n(head,step+1);
	printf("%d",div->val);
	last->next=head;
	head=div->next;
	div->next=NULL;
	return head;
}
int main()
{
	return 0;
}
